﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml;

namespace GameBanChim_Version1
{
    public class Background : Dialog
    {
        public override bool Init(ContentManager Content, int index, string strResourceXML)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(strResourceXML);

            XmlNode _backGround = doc.DocumentElement.SelectSingleNode("//BackGround[@id='" + index.ToString() + "']");

            XmlNodeList _listOfImage = _backGround.SelectNodes("Image");
            Texture2D[] _temp = new Texture2D[_listOfImage.Count];
            for (int i = 0; i < _listOfImage.Count; i++)
            {
                _temp[0] = Content.Load<Texture2D>(_listOfImage[i].InnerText);
            }

            Nsprite = 1;
            Sprite = new MySprite[Nsprite];
            Sprite[0] = new MySprite(_temp, 0, 0, 0);
            X = int.Parse(_backGround.SelectSingleNode("X").InnerText);
            Y = int.Parse(_backGround.SelectSingleNode("Y").InnerText);
            return true;
        }

        public override VisibleGameObject Clone()
        {
            Background _newBackGround = new Background();
            _newBackGround.Nsprite = Nsprite;
            _newBackGround.Sprite = new MySprite[_newBackGround.Nsprite];
            for (int i = 0; i < _newBackGround.Nsprite; i++)
            {
                _newBackGround.Sprite[i] = Sprite[i];
            }
            _newBackGround.X = X;
            _newBackGround.Y = Y;
            return _newBackGround;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            base.Draw(gameTime, spriteBatch);
        }
    }
}
